#pragma once

#include "TxNN/common.h"

namespace txinfer {

/*
 * SpinLock
 */
class SpinLock _TX_FINAL : public ISpinLock {
public:
  void lock() _TX_NOEXCEPT _TX_OVERRIDE {
    while (lock_.test_and_set()) {
      /* code blank */
    }
  }

  void unlock() _TX_NOEXCEPT _TX_FINAL { lock_.clear(); }
};

} // namespace txinfer